/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.aeso.betabit.dao;

import br.aeso.betabit.entity.Apostador;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

/**
 *
 * @author Edson
 */
public class ApostadorDao extends AbstractDao<Apostador>{
	
    @Override
	public List<Apostador> consultar() {
		EntityManager manager = null;
		try {
			manager = factory.createEntityManager();
			CriteriaBuilder builder = manager.getCriteriaBuilder();
			CriteriaQuery<Apostador> criteria = builder.createQuery(Apostador.class);
			Root<Apostador> categoria = criteria.from(Apostador.class);
			criteria.select(categoria);
			TypedQuery<Apostador> query = manager.createQuery(criteria);
			List<Apostador> result = query.getResultList();
			return result;
		} finally {
			manager.close();
		}
	}
}